feat: show expires at and remaining columns in lease listing#343
Conversation
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaces lease listing columns "BEGIN TIME" and "DURATION" with "EXPIRES AT" and "REMAINING"; adds Lease helpers to compute expiration and remaining time; and adds unit and e2e tests validating the new display and computation logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
e2e/tests.bats (1)
345-357: Make this E2E test self-contained to avoid order dependence.This test depends on suite-prepared state (
test-client-oidc, active exporters) and usesjmp delete leases --all, which broadens side effects beyond the lease created here. Please make setup/cleanup local to this test so it can run deterministically in isolation.Based on learnings: "E2E tests in bats should be runnable in isolation. Do not rely on prior suite setup or shared state across tests."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/tests.bats` around lines 345 - 357, This test is order-dependent because it relies on pre-existing client and exporter state and uses a global cleanup; modify the test to be self-contained by creating and using a unique test client (instead of relying on "jmp config client use test-client-oidc"), ensure any required exporter is started or validated with wait_for_exporter, create the lease with a unique selector/label so it’s identifiable, capture the created lease identifier from the "jmp create lease" output, assert on "jmp get leases" as before, and then delete only that specific lease (and the test client) rather than calling "jmp delete leases --all" so setup and teardown are local to the test.python/packages/jumpstarter/jumpstarter/client/grpc_test.py (1)
443-449: Add a deterministic non-expiredREMAININGassertion.Current tests validate
expiredandNone, but not the positive formatting output (Xd Yh Zm). Adding one fixed-clock test would better protect the new display behavior from regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py` around lines 443 - 449, Add a deterministic positive-case test for Lease._format_remaining that asserts a future datetime produces the expected "Xd Yh Zm" string: create a fixed "now" (e.g., datetime(2020,1,1,0,0,0)), compute a future time (e.g., now + timedelta(days=1, hours=2, minutes=3)), call Lease._format_remaining(future_time) and assert it equals "1d 2h 3m"; add this as test_format_remaining_future in grpc_test.py and ensure the test uses the fixed clock (or computes expected output from that fixed reference) so it is deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@e2e/tests.bats`:
- Around line 345-357: This test is order-dependent because it relies on
pre-existing client and exporter state and uses a global cleanup; modify the
test to be self-contained by creating and using a unique test client (instead of
relying on "jmp config client use test-client-oidc"), ensure any required
exporter is started or validated with wait_for_exporter, create the lease with a
unique selector/label so it’s identifiable, capture the created lease identifier
from the "jmp create lease" output, assert on "jmp get leases" as before, and
then delete only that specific lease (and the test client) rather than calling
"jmp delete leases --all" so setup and teardown are local to the test.
In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py`:
- Around line 443-449: Add a deterministic positive-case test for
Lease._format_remaining that asserts a future datetime produces the expected "Xd
Yh Zm" string: create a fixed "now" (e.g., datetime(2020,1,1,0,0,0)), compute a
future time (e.g., now + timedelta(days=1, hours=2, minutes=3)), call
Lease._format_remaining(future_time) and assert it equals "1d 2h 3m"; add this
as test_format_remaining_future in grpc_test.py and ensure the test uses the
fixed clock (or computes expected output from that fixed reference) so it is
deterministic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 13b28fb4-15ef-4f17-9102-6798826273fe
📒 Files selected for processing (3)
e2e/tests.batspython/packages/jumpstarter/jumpstarter/client/grpc.pypython/packages/jumpstarter/jumpstarter/client/grpc_test.py
…rter-dev#32) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f958df9 to
6c0aafe
Compare
…eases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
212a314 to
583f539
Compare
Rich wraps the "EXPIRES AT" column header across two lines when the terminal is narrower than the table, causing the substring assertion to fail in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kirkbrauer
left a comment
There was a problem hiding this comment.
This looks good! Just a few optimizations to make and I think we're good to merge.
Add deterministic positive-case tests for _format_remaining and scope E2E test cleanup to delete only the specific lease instead of --all. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 30a6bc5.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
python/packages/jumpstarter/jumpstarter/client/grpc_test.py (1)
443-448: Consider adding a test for future datetime remaining format.Tests cover the
"expired"and""cases, but there's no explicit test verifying the human-readable remaining duration format (e.g.,"2h 15m") for future datetimes. This is the primary use case for the REMAINING column.💡 Suggested additional test
def test_format_remaining_future(self): # Use a datetime far enough in the future to avoid flakiness from datetime import timezone future = datetime.now(timezone.utc).replace(tzinfo=None) + timedelta(hours=2, minutes=30) result = Lease._format_remaining(future) # Should return a non-empty human-readable string assert result != "" assert result != "expired" # Optionally verify format contains time units assert "h" in result or "m" in result or "d" in result🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py` around lines 443 - 448, Add a test named test_format_remaining_future that calls Lease._format_remaining with a datetime sufficiently in the future (e.g., datetime.now() + timedelta(hours=2, minutes=30)) to avoid flakiness; assert the return is not empty, not "expired", and contains at least one time unit character like "h", "m", or "d" to verify the human-readable remaining-duration format produced by Lease._format_remaining.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@python/packages/jumpstarter/jumpstarter/client/grpc_test.py`:
- Around line 443-448: Add a test named test_format_remaining_future that calls
Lease._format_remaining with a datetime sufficiently in the future (e.g.,
datetime.now() + timedelta(hours=2, minutes=30)) to avoid flakiness; assert the
return is not empty, not "expired", and contains at least one time unit
character like "h", "m", or "d" to verify the human-readable remaining-duration
format produced by Lease._format_remaining.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 66f83587-db0c-47bd-83d9-6e9ce6fd5f05
📒 Files selected for processing (3)
e2e/tests.batspython/packages/jumpstarter/jumpstarter/client/grpc.pypython/packages/jumpstarter/jumpstarter/client/grpc_test.py
🚧 Files skipped from review as they are similar to previous changes (2)
- e2e/tests.bats
- python/packages/jumpstarter/jumpstarter/client/grpc.py
…tting Replace manual divmod calculations with timedelta's built-in properties and add tests covering the formatting logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@kirkbrauer @mangelajo please take another look |
Summary
BEGIN TIMEandDURATIONcolumns withEXPIRES ATandREMAININGinjmp get leasesoutputEXPIRES ATshows the calculated expiration timestampREMAININGshows human-readable time left (e.g.2h 15m) orexpiredFixes #32
Test plan
test_rich_add_columns_has_expires_at_and_remaining)test_compute_expires_at_*)test_format_remaining_*)test_rich_add_rows_*)jmp get leasesoutput contains EXPIRES AT and REMAINING columns🤖 Generated with Claude Code